import 'package:cat_eye/base/base_refresh_view_model.dart';
import 'package:cat_eye/bean/home_body_bean.dart';
import 'package:cat_eye/config/url_config.dart';

/*
* @Package: view_model.find_view_model
* @ClassName: find_special_view_model
* @Author: szj
* @CreateDate: 8/2/21 7:09 PM
* TODO 发现-专题-ViewModel
*/
class FindSpecialViewModel extends BaseRefreshViewModel {
  String loadMoreUrl = "";

  List<ItemList> itemList = [];

  @override
  String get httpLoadMoreUrl => loadMoreUrl;

  @override
  String get httpUrl => UrlConfig.topicsUrl;

  @override
  void refresh() {
    if (itemList.length > 0) itemList.clear();
    super.refresh();
  }

  @override
  void successJsonData(json) {
    var bean = IssueList.fromJson(json);

    //下一条数据
    loadMoreUrl = bean.nextPageUrl;

    bean.itemList.forEach((element) {
      if (element.data != null && element.data.image != null &&
          element.data.image != "")
        itemList.add(element);
    });
  }
}
